<?php

namespace app\api\controller\Home;

use think\Controller;

class Home extends Controller
{
    
    public function index()
    {
        // 分类
        $TypeList = model('Product.Type')->order('weigh','desc')->limit(8)->select();

        $NewLit = model('Product.Product')->where(['flag' => 1])->limit(4)->select();

        $data = [
            'TypeList' => $TypeList,
            'NewList' => $NewLit
        ];

        $this->success('查询成功',null,$data);
    }
	
	public function banner()
	{
	   
	    $list = model('Product.Product')->where(['flag' => 3])->limit(5)->select();
	
	    $this->success('查询成功',null,$list);
	}
	
	// 查看帖子
	public function details(){
		
		// 获取数据
		$id = $this->request->param('id');
			
		$result = model('Post.Post')->where(['id' => $id])->find();
		
		if($result === FALSE)
		{
			$this->error('查询失败');	
		}else{
			// cookie('LoginUser',null);
			$this->success('查询成功',url('admin/post/postlist'),$result,0);
		}
		
	}
	
}
